//NeedAuth.js 用于查看state里的登录状态，如果有登录，就显示此组件的children，如果没有则跳转到LoginPage
import React from 'react'
import { useSelector } from 'react-redux'

import NoAuth from './NoAuth';

const NeedRole = props => {
    const loginstate = useSelector(state => state.loginpara);
    //children小写，很容易搞错
    return loginstate.isLogined&loginstate.role.loginname==="admin" ? props.children :  <NoAuth/>;

};

export default NeedRole
